package com.mz.ozy.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.mz.ozy.R;
import com.mz.ozy.utils.glideUtils.GlideUtils;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class HomeSpikeGridAdapter extends BaseAdapter {


    private Context mContext;
    List<Integer> mApListBeans ;
    public HomeSpikeGridAdapter(Context context, List<Integer> mApListBeans ) {
        this.mContext = context;
        this.mApListBeans = mApListBeans;
    }

    @Override
    public int getCount() {
        return mApListBeans.size();
    }

    @Override
    public Object getItem(int position) {
        return position;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if(convertView == null){
            convertView = LayoutInflater.from(mContext).inflate(R.layout.item_home_spike_grid, null);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        }else {
            holder = (ViewHolder) convertView.getTag();
        }
        GlideUtils.loadImg(mContext,holder.mHdImage,mApListBeans.get(position));
        return convertView;
    }


    class ViewHolder {

        @BindView(R.id.hdImage)
        ImageView mHdImage;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
